<% if index && !details[:covering_index] %>
  <% unless @debug %>
    <div class="show-details">Details</div>
  <% end %>
  <code><pre class="create-index">CREATE INDEX CONCURRENTLY ON <%= index[:table] %><% if index[:using] %> USING <%= index[:using] %><% end %> (<%= index[:columns].join(", ") %>)</pre></code>
<% end %>
<div class="details<%= " hide" unless @debug %>">
  <code><pre><% if details[:explanation] %><%= details[:explanation] %>
<% end %><% if details[:row_estimates] %>Rows: <%= details[:rows] %>
<% if details[:row_progression] %>Row progression: <%= details[:row_progression].to_a.join(", ") %>
<% end %>

Row estimates
<%= details[:row_estimates].to_a.map { |k, v| "- #{k}: #{v}" }.join("\n") %><% end %><% if details[:table_indexes] %>

Existing indexes
<% details[:table_indexes].sort_by { |i| [i[:primary] ? 0 : 1, i[:columns]] }.each do |i3| %>- <%= i3[:columns].join(", ") %><% if i3[:using] != "btree" %> <%= i3[:using].to_s.upcase %><% end %><% if i3[:primary] %> PRIMARY<% elsif i3[:unique] %> UNIQUE<% end %>
<% end %><% end %></pre></code>
</div>
